<template>
    <var-dialog
        title="分享"
        v-model:show="dialogStore.isShareTemplateDialogVisible"
        dialog-class="m-share-template-dialog"
        :confirm-button="false"
        cancelButtonText="关闭"
    >
        <div class="m-share-template-dialog__top">
            <div class="share-title">
                {{ dialogStore.shareTitle || "作品链接" }}
            </div>
            <div class="share-url-box">{{ dialogStore.shareUrl }}</div>
            <div class="copy-btn" @click="onCopyUrl">复制</div>
        </div>

        <div class="m-share-template-dialog__bottom">
            <div class="qrcode">
                <img :src="QrCodeUrl" />
            </div>
            <div class="tips">长按图片保存到相册</div>
            <!-- <var-button
                type="primary"
                text
                outline
                size="small"
                @click="onDownloadQrCode"
            >
                下载二维码
            </var-button> -->
        </div>
    </var-dialog>
</template>
<script setup>
import { useContent } from ".";
const { dialogStore, QrCodeUrl, onCopyUrl, onDownloadQrCode } = useContent();
</script>
<style lang="scss">
.m-share-template-dialog {
    border-radius: 10px !important;
    user-select: none;

    &__main {
        display: flex;
        padding: 0 20px;
    }

    &__top {
        display: flex;
        flex-direction: column;
        padding-top: 20px;

        .share-title {
            font-size: 14px;
            color: #333;
        }

        .share-url-box {
            width: 100%;
            line-height: 30px;
            font-size: 14px;
            padding: 0 9px;
            margin-top: 10px;
            border: 1px solid #ddd;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            box-sizing: border-box;
        }

        .copy-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 60px;
            height: 28px;
            margin-top: 10px;
            margin-left: auto;
            color: #fff;
            background-color: #5085fb;
            border-radius: 4px;
            cursor: pointer;
        }
    }

    &__bottom {
        text-align: center;
        margin-top: 10px;

        .qrcode {
            width: 140px;
            height: 140px;
            margin: 0 auto 10px;

            img {
                width: 100%;
                height: 100%;
            }
        }
    }
}
</style>
